<%@ page import="java.util.Enumeration" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Arrays" %><%--
  Created by IntelliJ IDEA.
  User: Think
  Date: 2024/7/23
  Time: 下午3:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Jsp客户端请求</title>
</head>
<body>
<h1>HTTP头部请求</h1>
<table border = "1">
    <tr>
        <th>Header Name</th>
        <th>Header Values</th>
    </tr>
    <%
        Enumeration<String> headerNames = request.getHeaderNames();
        while (headerNames.hasMoreElements()) {
            String paramName = headerNames.nextElement();
            out.print("<tr><td>" + paramName + "</td>\n");
            String paramValue = request.getHeader(paramName);
            out.println("<td>" + paramValue + "</td></tr>\n");
        }
    %>
</table>
<h1>返回客户端所有的Cookies的数组</h1>
<% List<Cookie> cookies = Arrays.asList(request.getCookies());
    for(Cookie cookie:cookies){
        out.println("cookie名称："+cookie.getName()+"</br>");
        out.println("cookie值"+cookie.getValue()+"</br>");
    }
%>
<h1>返回request对象的所有属性名称的集合</h1>
<table border = "1">
    <tr>
        <th>attribute Name</th>
        <th>attribute Values</th>
    </tr>
    <%
        Enumeration<String> attributeNames = request.getAttributeNames();
        while (attributeNames.hasMoreElements()) {
            String paramName = attributeNames.nextElement();
            out.print("<tr><td>" + paramName + "</td>\n");
            String paramValue = (String) request.getAttribute(paramName);
            out.println("<td>" + paramValue + "</td></tr>\n");
        }
    %>
</table>
</body>
</html>
